package com.jiang.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.jiang.utils.RequestUtils;
import lombok.Data;

import java.util.Date;

/**
 * <p>
 * 部门表
 * </p>
 *
 * @author jason
 * @since 2019-03-18
 */
@TableName("sys_dept")
@Data
public class Dept extends Model<Dept> {

    private static final long serialVersionUID = 1L;

    /**
     * 主键id
     */
    @TableId(value = "DEPT_ID", type = IdType.AUTO)
    private Long deptId;
    /**
     * 父部门id
     */
    private Long pid;
    /**
     * 父级ids
     */
    private String pids;

    private String simpleName;

    private String fullName;

    private String description;

    private Integer version;

    private Integer sort;

    private Date createTime;

    private Date updateTime;
    /**
     * 创建人
     */
    private Long createUser;
    /**
     * 修改人
     */
    private Long updateUser;


    public void preInsert(){
        this.createTime = new Date();
        this.createUser = RequestUtils.getCurrentUser().getUserId();
        this.version = 0;
    }

    public void preUpdate(){
        this.updateTime = new Date();
        this.updateUser = RequestUtils.getCurrentUser().getUserId();
    }
}
